import math
import numpy as np
import pickle
from scipy import interpolate
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.optimize import minimize
from scipy.optimize import brute
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)


spectral_template=pickle.load(open("spectral_template_lime_stacked.pickle", "rb"))
spectral_template_coms=pickle.load(open("spectral_template_stacked.pickle", "rb"))

fig,ax=plt.subplots(1,1,figsize=(15, 10))
ax.plot(spectral_template['freq_axis']/1e9,spectral_template['spectrum'],drawstyle='steps',linewidth='2',label='LIME Model')
ax.plot(spectral_template_coms['freq_axis']/1e9,spectral_template_coms['spectrum'],drawstyle='steps',linewidth='2',label='CH$_3$OH Spectra')

ax.legend(fontsize=22)
ax.xaxis.set_major_locator(MultipleLocator(0.005))
ax.xaxis.set_minor_locator(AutoMinorLocator())
ax.tick_params(which='both', width=2)
ax.tick_params(which='major', length=8,labelsize=20)
ax.tick_params(which='minor', length=4)
ax.set_ylabel('Normalized Units',fontsize=22)
ax.set_xlabel('Frequency (GHz)',fontsize=22)
ax.set_xlim(np.min(spectral_template['freq_axis']/1e9),np.max(spectral_template['freq_axis']/1e9))
ax.set_ylim(-0.05,1.2)
plt.savefig('Spectral_Templates_stacked.png')
plt.savefig('Spectral_Templates_stacked.pdf')

